home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_gen / janusw.zip / VBXDEMO2.PAS < prev    next >
Pascal/Delphi Source File  |  1994-05-16  |  4KB  |  190 lines

  1. { Program:   VbxDemo2
  2.   Version:   1.0
  3.   Purpose:   Demo program to show use of dynamically created VBX custom controls
  4.   Date:      12 March 1994
  5.   Developer: Frank Lees (FL)
  6.              Phoenix, Arizona
  7.   CompuServe: 71532,2133
  8.  
  9.  
  10.  Copyright (c) 1994 Frank Lees, Peter Sawatzki. All Rights Reserved.
  11. }
  12. Program VbxDemo2;
  13. {$R VbxDemo2.Res}
  14. Uses
  15.   WinProcs,
  16.   oWindows,
  17.   oDialogs,
  18.   WinTypes,
  19.   Strings,
  20.   ThreeD,   { VBX Definition - Generated by VBXInfo }
  21.   Grid,     { VBX definition - Generated by VBXInfo }
  22.   Vbx;      { Interface to BIVBX10.DLL }
  23.  
  24. Const
  25.   VBXvalidation: tVbxValidation = cVbxValidation;
  26.  
  27. type { derived object against TPanel generated by VBXINFO }
  28.   PMyPanel =^TMyPanel;
  29.   TMyPanel = object(TSSPanel)
  30.     procedure SetupWindow; virtual;
  31.   end;
  32.  
  33. type { derived object against TGrid generated by VBXINFO }
  34.   PMyGrid =^TMyGrid;
  35.   TMyGrid = object(TGrid)
  36.     procedure SetupWindow; virtual;
  37.     Procedure evClick     (Var Event: tVbxEvent); Virtual ev_First+0;
  38.     Procedure evSelChange (Var Event: tVbxEvent); Virtual ev_First+13;
  39.   end;
  40.  
  41. type { Main Window }
  42.   pMyWindow = ^tMyWindow;
  43.   tMyWindow = Object(tVbxWindow)
  44.     ctl1: PMyPanel;
  45.     ctl2: PMyGrid;
  46.     btBusy,btFree: PButton;
  47.     Constructor Init (aParent: pWindowsObject; Name: pChar);
  48.     Procedure SetupWindow; Virtual;
  49.   End;
  50.  
  51. procedure TMyPanel.SetupWindow;
  52. {- Setup 3D Panel }
  53. var
  54.   x,y:integer;
  55. const
  56.   GRIDROWS=20;
  57.   GRIDCOLS=8;
  58.   DayTab:array[1..7] of PChar = ('Mon','Tue','Wed','Thu','Fri','Sat','Sun');
  59. begin
  60.   inherited SetupWindow;
  61.   SetPropAlignment(aCenterMiddle);
  62.   SetPropBorderWidth(1);
  63.   SetPropBevelWidth(3);
  64.   SetPropBevelOuter(boInset);
  65.   SetPropBevelInner(biInset);
  66.   SetPropCaption('Appointments');
  67.   SetPropFontName('Arial');
  68.   SetPropFontSize(12);
  69.   SetPropFontBold(TRUE);
  70.   SetPropFont3d(fdInsetwlightshading);
  71.   SetPropFontUnderLine(FALSE);
  72.   SetPropFontStrikeThru(FALSE);
  73.  
  74.   SetPropBackColor(RGB(192,192,192));
  75. end;
  76.  
  77. procedure TMyGrid.SetupWindow;
  78. {- Setup Grid Control }
  79. var
  80.   x,y:integer;
  81.   pHour: array[0..5] of char;
  82. const
  83.   GRIDROWS=25;
  84.   GRIDCOLS=8;
  85.   DayTab:array[1..7] of PChar = ('Mon','Tue','Wed','Thu','Fri','Sat','Sun');
  86. begin
  87.   inherited SetupWindow;
  88.   SetPropRows(GRIDROWS);
  89.   SetPropCols(GRIDCOLS+1);
  90.   SetPropBackColor(RGB(0,255,0));
  91.   SetPropByName('Scrollbars',3);
  92.  
  93.   { Grid Headings }
  94.   SetPropRow(0);
  95.   for x:=1 to GRIDCOLS+1 do
  96.     begin
  97.       SetPropCol(x);
  98.       SetPropText(Daytab[x]);
  99.       SetPropFontBold(FALSE);
  100.     end;
  101.  
  102.   SetPropCol(0);
  103.   for x:=1 to GRIDROWS-1 do
  104.     begin
  105.       SetPropRow(x);
  106.       WVSprintf(pHour,'%02i:00',x);
  107.       SetPropText(pHour);
  108.       SetPropFontBold(FALSE);
  109.     end;
  110.  
  111.   for x:=1 to GridRows-1 do
  112.     for y:=1 to GridCols-1 do
  113.       begin
  114.         SetPropRow(x);
  115.         SetPropCol(y);
  116.         SetPropText('Free');
  117.       end;
  118.  
  119.    { Load a Bitmap and an icon into the grid }
  120.    SetPropRow(0);
  121.    SetPropCol(0);
  122.    SetPropPicture(dVbx.LoadPicture('BM1',PICTYPE_BITMAP));
  123. {
  124.   for x:=1 to 7 do
  125.     begin
  126.       SetPropByName('Row',x); SetPropByName('Col',x);
  127.       SetPropPicture(LoadPicture('IC1',PICTYPE_ICON));
  128.    end;
  129.  }
  130. end;
  131.  
  132. procedure TMyGrid.evClick(Var Event: tVBXEvent);
  133. begin
  134. {  MessageBox(0,'Click','',mb_ok);    }
  135. end;
  136.  
  137. Procedure TMyGrid.evSelChange (Var Event: tVbxEvent);
  138. var
  139.   x1,x2,y1,y2: integer;
  140. begin
  141.   GetPropSelStartRow (y1);
  142.   GetPropSelEndRow (y2);
  143.   GetPropSelStartCol(x1);
  144.   GetPropSelEndCol(x2);
  145. end;
  146.  
  147.  
  148. Procedure tMyWindow.SetupWindow;
  149. Begin
  150.   Inherited SetupWindow;
  151. End;
  152.  
  153. Constructor tMyWindow.Init (aParent: pWindowsObject; Name: pChar);
  154. Begin
  155.   inherited Init(aParent,Name);
  156.   Attr.W:=500;
  157.   Attr.H:=450;
  158.   ctl1:=new(PMyPanel,Init(@self,100,'Panel100',10,10,300,75,0,NIL));
  159.   ctl2:=new(PMyGrid,Init(@self,101,'Grid101',10,120,380,250,0,NIL));
  160.   btFree:=new(PButton,Init(@self,500,'&Free',420,150,50,20,FALSE));
  161.   btBusy:=new(PButton,Init(@self,501,'&Busy',420,200,50,20,FALSE));
  162.  
  163. End;
  164.  
  165.  
  166. {-------------------- the Application part }
  167. Const
  168.   ProgName = 'VbxDemo2';
  169. Type
  170.   tProgApp = Object(tApplication)
  171.     Procedure InitMainWindow; Virtual;
  172.   End;
  173.  
  174. Procedure tProgApp.InitMainWindow;
  175. Begin
  176.   MainWindow:= New(pMyWindow, Init(Nil, 'Dynamically Created VBX Control Demo'))
  177. End;
  178.  
  179. Var
  180.   App: tProgApp;
  181. Begin
  182.   RegisterVBX(VBXvalidation);
  183.   With App Do Begin
  184.     Init(ProgName);
  185.     Run;
  186.     Done
  187.   End
  188. End.
  189.  
  190.